/**
 *@file  gd32l23x_it.c
 *@brief interrupt service routines
*/
#include "gd32l23x_it.h"
#include "systick.h"

#define SRAM_ECC_ERROR_HANDLE(s) \
    do                           \
    {                            \
    } while (1)

volatile static uint32_t _sys_tick = 0u;
uint32_t get_sys_tick(void)
{
    return _sys_tick;
}

/*!
    \brief      this function handles NMI exception
    \param[in]  none
    \param[out] none
    \retval     none
*/
void NMI_Handler(void)
{
    if (SET == syscfg_flag_get(SYSCFG_FLAG_SRAM_PCEF))
    {
        SRAM_ECC_ERROR_HANDLE("SRAM parity check error\r\n");
    }
    else
    {
        /* if NMI exception occurs, go to infinite loop */
        /* HXTAL clock monitor NMI error or NMI pin error */
        while (1)
        {
        }
    }
}

/*!
    \brief      this function handles HardFault exception
    \param[in]  none
    \param[out] none
    \retval     none
*/
void HardFault_Handler(void)
{
    /* if Hard Fault exception occurs, go to infinite loop */
    while (1)
    {
    }
}

/*!
    \brief      this function handles SVC exception
    \param[in]  none
    \param[out] none
    \retval     none
*/
void SVC_Handler(void)
{
    /* if SVC exception occurs, go to infinite loop */
    while (1)
    {
    }
}

/*!
    \brief      this function handles PendSV exception
    \param[in]  none
    \param[out] none
    \retval     none
*/
void PendSV_Handler(void)
{
    /* if PendSV exception occurs, go to infinite loop */
    while (1)
    {
    }
}

/*!
    \brief      this function handles SysTick exception
    \param[in]  none
    \param[out] none
    \retval     none
*/
void SysTick_Handler(void)
{
    _sys_tick++;
    delay_decrement();
}
